<?php
class ErrorForm extends Form
{
	function ErrorForm()
	{
		Form::Form('ErrorForm');

		
		####################################################
		#Redirect 301
		
		/*
		if(DEBUG)
		{
			echo $_SERVER['HTTP_REFERER'],'<br />';
			echo $REQUEST_URI;
		}
		*/
		
		if((isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER'] != '') || ECLib::is_search_engine())
		{
			$HTTP_REFERER 	= $_SERVER['HTTP_REFERER'];
			//$REQUEST_URI 	= substr(WEB_ROOT,0,-1) . $_SERVER['REQUEST_URI'];
			$REQUEST_URI 	= WEB_ROOT . substr($_SERVER['REQUEST_URI'],strlen(WEB_DIR));
			
			if(($HTTP_REFERER != $REQUEST_URI && strpos($HTTP_REFERER, WEB_ROOT) === false) || ECLib::is_search_engine())
			{
				//header_remove(); 
				//header_remove('Status');
				
				Url::redirect_url(false, 301);
			}
		}
		
		//standard method # 
		header("HTTP/1.0 404 Not Found");
		
		CGlobal::$website_title = "404 - Nội dung bạn tìm kiếm không tồn tại";
	}
	
	function draw()
	{
		global $display;
		//$display->add('category_id',CGlobal::$curCat);
		$display->add('base_url',WEB_DIR);
		$display->output('404_error');
	}
}
?>